<?php
/**
 * Created by PhpStorm.
 * User:tsingStar
 * Date: 2019/7/19
 * Time: 13:11
 */

namespace app\home\controller;


use app\common\model\Storage;

class Upload extends Common
{
    protected function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
        header("content-type:application/json");
        $storage = new Storage();
        $res = $storage->upload("image", ["png", "jpg", "jpeg"]);
        if($res["status"] == 0){
            //上传成功
            die(json_encode([
                "result_code"=>"0000",
                "result_data"=>$res["data"],
                "result_info"=>"上传成功"
            ]));

        }else{
            //上传失败
            die(json_encode([
                "result_code"=>1,
                "result_data"=>$res["data"],
                "result_info"=>"上传失败"
            ]));
        }
    }

}